<!DOCTYPE html>
<HTML>
<HEAD>
    <TITLE>闺蜜会员等级结构</TITLE>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" href="/statics/css/ztree_css/demo.css" type="text/css">
    <link rel="stylesheet" href="/statics/css/ztree_css/zTreeStyle/zTreeStyle.css" type="text/css">
    <script src="/statics/js/ztree_js/jquery-1.4.4.min.js"></script>
    <script src="/statics/js/ztree_js/jquery.ztree.core.js"></script>
</HEAD>

<!--  <script type="text/javascript" src="../../../js/jquery.ztree.excheck.js"></script>
  <script type="text/javascript" src="../../../js/jquery.ztree.exedit.js"></script>-->
<SCRIPT type="text/javascript">
    var setting = {
        data: {
            simpleData: {
                enable: true
            }
        },
        view: {
            showIcon: showIconForTree,
            fontCss: setFontCss
        }
    };
    function showIconForTree(treeId, treeNode) {
        return treeNode.level == -1;
    };
    function setFontCss(treeId, treeNode) {
        return treeNode.level == 0 ? {color:"red"} : {};
    };
    <?php
        function tree2html($list,$times=0)
        {
            $separator = '&nbsp;&nbsp;';
            for($i = 0; $i < $times; $i++){
                $separator .= '&nbsp;&nbsp;';
            }
            foreach ($list as $row) {
            ?>
            { id:<?=$row['cust_id'];?>, pId:<?=$row['parent_rmi_id']?:0;?>, open:'true', name:"<?=$row['cust_realname'];?>（<?=$row['cust_mobile']?>）[<?=date('Y-m-d',$row['add_at'])?>]"},
        <?php
            if (!empty($row['list'])){
                tree2html($row['list'],++$times);
            }
        }
        }?>

    var zNodes =[
    <?php if($getData){foreach($getData AS $key=>$val){?>
        { id:<?=$val['cust_id'];?>, pId:<?=$val['parent_id']?:0?>, name:"<?=$val['cust_realname'];?>（<?=$val['cust_mobile']?>）[<?=date('Y-m-d',$val['add_at'])?>]", open:true},
    <?php tree2html($val['list'],1); ?>

    <?php }} ?>
    ];



    $(document).ready(function(){
        $.fn.zTree.init($("#treeDemo"), setting, zNodes);
    });
</SCRIPT>
<body>
<div class="row-fluid" ><br>
    <span style="color:red;padding-left:15px"><b>温馨提示：下面结构中的红色用户为 顶级代理</b></span>
    <hr style="margin-top: 0px;margin-bottom: -13px;">
    <div class="content_wrap" style="margin-left:25px">
        <div class="zTreeDemoBackground left">
            <ul id="treeDemo" class="ztree" style="width: 900px;height: auto; border: 0;background-color: transparent"></ul>
        </div>


    </div>
</div>
</body>
</HTML>